package com.dalin.demo.service.imple;

import com.dalin.demo.dao.StudentMapper;
import com.dalin.demo.dao.TeacherMapper;
import com.dalin.demo.pojo.entity.Student;
import com.dalin.demo.pojo.entity.StudentClass;
import com.dalin.demo.pojo.entity.Teacher;
import com.dalin.demo.pojo.entity.TeacherCourse;
import com.dalin.demo.service.StudentService;
import com.dalin.demo.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    public List<Teacher> listTeachersByParams(Map<String, Object> params) {
        return teacherMapper.listTeachersByParams(params);
    }

    public Integer addTeacher(Teacher teacher) {
        teacherMapper.insertTeacher(teacher);
        return teacher.getTeacherId();
    }

    public Integer updateTeacher(Teacher teacher) {
        teacherMapper.updateTeacher(teacher);
        return teacher.getTeacherId();
    }

    public Integer deleteTeacher(int id) {
        teacherMapper.deleteTeacherById(id);
        return id;
    }

    public void batchAddClass(List<TeacherCourse> teacher) {
        teacherMapper.batchInsert(teacher);
    }

    @Override
    public List<TeacherCourse> getEnrolledTeacherByCourseId(Long teacherId) {
        return teacherMapper.findTeacherByClassId(teacherId);
    }
    public Integer deleteTeachers(int id) {
        teacherMapper.deleteTeachersById(id);
        return id;
    }
}